/**
 * This is a generated class and is not intended for modification.  To customize behavior
 * of this value object you may modify the generated sub-class of this class - Usuario.as.
 */

package valueObjects
{
import com.adobe.fiber.services.IFiberManagingService;
import com.adobe.fiber.util.FiberUtils;
import com.adobe.fiber.valueobjects.IValueObject;
import flash.events.Event;
import flash.events.EventDispatcher;
import mx.binding.utils.ChangeWatcher;
import mx.collections.ArrayCollection;
import mx.events.PropertyChangeEvent;
import mx.validators.ValidationResult;

import flash.net.registerClassAlias;
import flash.net.getClassByAlias;
import com.adobe.fiber.core.model_internal;
import com.adobe.fiber.valueobjects.IPropertyIterator;
import com.adobe.fiber.valueobjects.AvailablePropertyIterator;

use namespace model_internal;

[ExcludeClass]
public class _Super_Usuario extends flash.events.EventDispatcher implements com.adobe.fiber.valueobjects.IValueObject
{
    model_internal static function initRemoteClassAliasSingle(cz:Class) : void
    {
        try
        {
            if (flash.net.getClassByAlias("Usuario") == null)
            {
                flash.net.registerClassAlias("Usuario", cz);
            }
        }
        catch (e:Error)
        {
            flash.net.registerClassAlias("Usuario", cz);
        }
    }

    model_internal static function initRemoteClassAliasAllRelated() : void
    {
    }

    model_internal var _dminternal_model : _UsuarioEntityMetadata;
    model_internal var _changedObjects:mx.collections.ArrayCollection = new ArrayCollection();

    public function getChangedObjects() : Array
    {
        _changedObjects.addItemAt(this,0);
        return _changedObjects.source;
    }

    public function clearChangedObjects() : void
    {
        _changedObjects.removeAll();
    }

    /**
     * properties
     */
    private var _internal_id : int;
    private var _internal_rut : String;
    private var _internal_nombre : String;
    private var _internal_apaterno : String;
    private var _internal_amaterno : String;
    private var _internal_rol : String;
    private var _internal_habilitado : Boolean;
    private var _internal_alias : String;
    private var _internal_contrasena : String;

    private static var emptyArray:Array = new Array();


    /**
     * derived property cache initialization
     */
    model_internal var _cacheInitialized_isValid:Boolean = false;

    model_internal var _changeWatcherArray:Array = new Array();

    public function _Super_Usuario()
    {
        _model = new _UsuarioEntityMetadata(this);

        // Bind to own data or source properties for cache invalidation triggering
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "rut", model_internal::setterListenerRut));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "nombre", model_internal::setterListenerNombre));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "apaterno", model_internal::setterListenerApaterno));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "amaterno", model_internal::setterListenerAmaterno));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "rol", model_internal::setterListenerRol));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "alias", model_internal::setterListenerAlias));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "contrasena", model_internal::setterListenerContrasena));

    }

    /**
     * data/source property getters
     */

    [Bindable(event="propertyChange")]
    public function get id() : int
    {
        return _internal_id;
    }

    [Bindable(event="propertyChange")]
    public function get rut() : String
    {
        return _internal_rut;
    }

    [Bindable(event="propertyChange")]
    public function get nombre() : String
    {
        return _internal_nombre;
    }

    [Bindable(event="propertyChange")]
    public function get apaterno() : String
    {
        return _internal_apaterno;
    }

    [Bindable(event="propertyChange")]
    public function get amaterno() : String
    {
        return _internal_amaterno;
    }

    [Bindable(event="propertyChange")]
    public function get rol() : String
    {
        return _internal_rol;
    }

    [Bindable(event="propertyChange")]
    public function get habilitado() : Boolean
    {
        return _internal_habilitado;
    }

    [Bindable(event="propertyChange")]
    public function get alias() : String
    {
        return _internal_alias;
    }

    [Bindable(event="propertyChange")]
    public function get contrasena() : String
    {
        return _internal_contrasena;
    }

    public function clearAssociations() : void
    {
    }

    /**
     * data/source property setters
     */

    public function set id(value:int) : void
    {
        var oldValue:int = _internal_id;
        if (oldValue !== value)
        {
            _internal_id = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "id", oldValue, _internal_id));
        }
    }

    public function set rut(value:String) : void
    {
        var oldValue:String = _internal_rut;
        if (oldValue !== value)
        {
            _internal_rut = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "rut", oldValue, _internal_rut));
        }
    }

    public function set nombre(value:String) : void
    {
        var oldValue:String = _internal_nombre;
        if (oldValue !== value)
        {
            _internal_nombre = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "nombre", oldValue, _internal_nombre));
        }
    }

    public function set apaterno(value:String) : void
    {
        var oldValue:String = _internal_apaterno;
        if (oldValue !== value)
        {
            _internal_apaterno = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "apaterno", oldValue, _internal_apaterno));
        }
    }

    public function set amaterno(value:String) : void
    {
        var oldValue:String = _internal_amaterno;
        if (oldValue !== value)
        {
            _internal_amaterno = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "amaterno", oldValue, _internal_amaterno));
        }
    }

    public function set rol(value:String) : void
    {
        var oldValue:String = _internal_rol;
        if (oldValue !== value)
        {
            _internal_rol = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "rol", oldValue, _internal_rol));
        }
    }

    public function set habilitado(value:Boolean) : void
    {
        var oldValue:Boolean = _internal_habilitado;
        if (oldValue !== value)
        {
            _internal_habilitado = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "habilitado", oldValue, _internal_habilitado));
        }
    }

    public function set alias(value:String) : void
    {
        var oldValue:String = _internal_alias;
        if (oldValue !== value)
        {
            _internal_alias = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "alias", oldValue, _internal_alias));
        }
    }

    public function set contrasena(value:String) : void
    {
        var oldValue:String = _internal_contrasena;
        if (oldValue !== value)
        {
            _internal_contrasena = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "contrasena", oldValue, _internal_contrasena));
        }
    }

    /**
     * Data/source property setter listeners
     *
     * Each data property whose value affects other properties or the validity of the entity
     * needs to invalidate all previously calculated artifacts. These include:
     *  - any derived properties or constraints that reference the given data property.
     *  - any availability guards (variant expressions) that reference the given data property.
     *  - any style validations, message tokens or guards that reference the given data property.
     *  - the validity of the property (and the containing entity) if the given data property has a length restriction.
     *  - the validity of the property (and the containing entity) if the given data property is required.
     */

    model_internal function setterListenerRut(value:flash.events.Event):void
    {
        _model.invalidateDependentOnRut();
    }

    model_internal function setterListenerNombre(value:flash.events.Event):void
    {
        _model.invalidateDependentOnNombre();
    }

    model_internal function setterListenerApaterno(value:flash.events.Event):void
    {
        _model.invalidateDependentOnApaterno();
    }

    model_internal function setterListenerAmaterno(value:flash.events.Event):void
    {
        _model.invalidateDependentOnAmaterno();
    }

    model_internal function setterListenerRol(value:flash.events.Event):void
    {
        _model.invalidateDependentOnRol();
    }

    model_internal function setterListenerAlias(value:flash.events.Event):void
    {
        _model.invalidateDependentOnAlias();
    }

    model_internal function setterListenerContrasena(value:flash.events.Event):void
    {
        _model.invalidateDependentOnContrasena();
    }


    /**
     * valid related derived properties
     */
    model_internal var _isValid : Boolean;
    model_internal var _invalidConstraints:Array = new Array();
    model_internal var _validationFailureMessages:Array = new Array();

    /**
     * derived property calculators
     */

    /**
     * isValid calculator
     */
    model_internal function calculateIsValid():Boolean
    {
        var violatedConsts:Array = new Array();
        var validationFailureMessages:Array = new Array();

        var propertyValidity:Boolean = true;
        if (!_model.rutIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_rutValidationFailureMessages);
        }
        if (!_model.nombreIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_nombreValidationFailureMessages);
        }
        if (!_model.apaternoIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_apaternoValidationFailureMessages);
        }
        if (!_model.amaternoIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_amaternoValidationFailureMessages);
        }
        if (!_model.rolIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_rolValidationFailureMessages);
        }
        if (!_model.aliasIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_aliasValidationFailureMessages);
        }
        if (!_model.contrasenaIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_contrasenaValidationFailureMessages);
        }

        model_internal::_cacheInitialized_isValid = true;
        model_internal::invalidConstraints_der = violatedConsts;
        model_internal::validationFailureMessages_der = validationFailureMessages;
        return violatedConsts.length == 0 && propertyValidity;
    }

    /**
     * derived property setters
     */

    model_internal function set isValid_der(value:Boolean) : void
    {
        var oldValue:Boolean = model_internal::_isValid;
        if (oldValue !== value)
        {
            model_internal::_isValid = value;
            _model.model_internal::fireChangeEvent("isValid", oldValue, model_internal::_isValid);
        }
    }

    /**
     * derived property getters
     */

    [Transient]
    [Bindable(event="propertyChange")]
    public function get _model() : _UsuarioEntityMetadata
    {
        return model_internal::_dminternal_model;
    }

    public function set _model(value : _UsuarioEntityMetadata) : void
    {
        var oldValue : _UsuarioEntityMetadata = model_internal::_dminternal_model;
        if (oldValue !== value)
        {
            model_internal::_dminternal_model = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "_model", oldValue, model_internal::_dminternal_model));
        }
    }

    /**
     * methods
     */


    /**
     *  services
     */
    private var _managingService:com.adobe.fiber.services.IFiberManagingService;

    public function set managingService(managingService:com.adobe.fiber.services.IFiberManagingService):void
    {
        _managingService = managingService;
    }

    model_internal function set invalidConstraints_der(value:Array) : void
    {
        var oldValue:Array = model_internal::_invalidConstraints;
        // avoid firing the event when old and new value are different empty arrays
        if (oldValue !== value && (oldValue.length > 0 || value.length > 0))
        {
            model_internal::_invalidConstraints = value;
            _model.model_internal::fireChangeEvent("invalidConstraints", oldValue, model_internal::_invalidConstraints);
        }
    }

    model_internal function set validationFailureMessages_der(value:Array) : void
    {
        var oldValue:Array = model_internal::_validationFailureMessages;
        // avoid firing the event when old and new value are different empty arrays
        if (oldValue !== value && (oldValue.length > 0 || value.length > 0))
        {
            model_internal::_validationFailureMessages = value;
            _model.model_internal::fireChangeEvent("validationFailureMessages", oldValue, model_internal::_validationFailureMessages);
        }
    }

    model_internal var _doValidationCacheOfRut : Array = null;
    model_internal var _doValidationLastValOfRut : String;

    model_internal function _doValidationForRut(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfRut != null && model_internal::_doValidationLastValOfRut == value)
           return model_internal::_doValidationCacheOfRut ;

        _model.model_internal::_rutIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isRutAvailable && _internal_rut == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "rut is required"));
        }

        model_internal::_doValidationCacheOfRut = validationFailures;
        model_internal::_doValidationLastValOfRut = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfNombre : Array = null;
    model_internal var _doValidationLastValOfNombre : String;

    model_internal function _doValidationForNombre(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfNombre != null && model_internal::_doValidationLastValOfNombre == value)
           return model_internal::_doValidationCacheOfNombre ;

        _model.model_internal::_nombreIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isNombreAvailable && _internal_nombre == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "nombre is required"));
        }

        model_internal::_doValidationCacheOfNombre = validationFailures;
        model_internal::_doValidationLastValOfNombre = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfApaterno : Array = null;
    model_internal var _doValidationLastValOfApaterno : String;

    model_internal function _doValidationForApaterno(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfApaterno != null && model_internal::_doValidationLastValOfApaterno == value)
           return model_internal::_doValidationCacheOfApaterno ;

        _model.model_internal::_apaternoIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isApaternoAvailable && _internal_apaterno == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "apaterno is required"));
        }

        model_internal::_doValidationCacheOfApaterno = validationFailures;
        model_internal::_doValidationLastValOfApaterno = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfAmaterno : Array = null;
    model_internal var _doValidationLastValOfAmaterno : String;

    model_internal function _doValidationForAmaterno(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfAmaterno != null && model_internal::_doValidationLastValOfAmaterno == value)
           return model_internal::_doValidationCacheOfAmaterno ;

        _model.model_internal::_amaternoIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isAmaternoAvailable && _internal_amaterno == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "amaterno is required"));
        }

        model_internal::_doValidationCacheOfAmaterno = validationFailures;
        model_internal::_doValidationLastValOfAmaterno = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfRol : Array = null;
    model_internal var _doValidationLastValOfRol : String;

    model_internal function _doValidationForRol(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfRol != null && model_internal::_doValidationLastValOfRol == value)
           return model_internal::_doValidationCacheOfRol ;

        _model.model_internal::_rolIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isRolAvailable && _internal_rol == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "rol is required"));
        }

        model_internal::_doValidationCacheOfRol = validationFailures;
        model_internal::_doValidationLastValOfRol = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfAlias : Array = null;
    model_internal var _doValidationLastValOfAlias : String;

    model_internal function _doValidationForAlias(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfAlias != null && model_internal::_doValidationLastValOfAlias == value)
           return model_internal::_doValidationCacheOfAlias ;

        _model.model_internal::_aliasIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isAliasAvailable && _internal_alias == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "alias is required"));
        }

        model_internal::_doValidationCacheOfAlias = validationFailures;
        model_internal::_doValidationLastValOfAlias = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfContrasena : Array = null;
    model_internal var _doValidationLastValOfContrasena : String;

    model_internal function _doValidationForContrasena(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfContrasena != null && model_internal::_doValidationLastValOfContrasena == value)
           return model_internal::_doValidationCacheOfContrasena ;

        _model.model_internal::_contrasenaIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isContrasenaAvailable && _internal_contrasena == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "contrasena is required"));
        }

        model_internal::_doValidationCacheOfContrasena = validationFailures;
        model_internal::_doValidationLastValOfContrasena = value;

        return validationFailures;
    }
    

}

}
